﻿using KC.Framework.Base;
using System;
using System.Collections.Generic;
using System.Text;

namespace KC.Framework.Tenant
{
    public class ApplicationConstant
    {
        #region 应用相关的常量
        public static readonly Guid SsoAppId = new Guid(SsoAppSId);
        public static readonly Guid AdminAppId = new Guid(AdminAppSId);
        public static readonly Guid BlogAppId = new Guid(BlogAppSId);

        public static readonly Guid AppAppId = new Guid(AppAppSId);
        public static readonly Guid ConfigAppId = new Guid(ConfigAppSId);
        public static readonly Guid DictAppId = new Guid(DictAppSId);
        public static readonly Guid MsgAppId = new Guid(MsgAppSId);
        
        public static readonly Guid AccAppId = new Guid(AccAppSId);
        public static readonly Guid EconAppId = new Guid(EconAppSId);
        public static readonly Guid DocAppId = new Guid(DocAppSId);
        public static readonly Guid HrAppId = new Guid(HrAppSId);

        public static readonly Guid CrmAppId = new Guid(CrmAppSId);
        public static readonly Guid SrmAppId = new Guid(SrmAppSId);
        public static readonly Guid PrdAppId = new Guid(PrdAppSId);
        public static readonly Guid PmcAppId = new Guid(PmcAppSId);

        public static readonly Guid PortalAppId = new Guid(PortalAppSId);
        public static readonly Guid SomAppId = new Guid(SomAppSId);
        public static readonly Guid PomAppId = new Guid(PomAppSId);
        public static readonly Guid WmsAppId = new Guid(WmsAppSId);

        public static readonly Guid MarketAppId = new Guid(MarketAppSId);

        public static readonly Guid TrainAppId = new Guid(TrainAppSId);

        public static readonly Guid FlowAppId = new Guid(FlowAppSId);
        public static readonly Guid PayAppId = new Guid(PayAppSId);

        public static readonly Guid WXapiAppId = new Guid(WXapiAppSId);
        public static readonly Guid ResapiAppId = new Guid(ResapiAppSId);
        public static readonly Guid WebapiAppId = new Guid(WebapiAppSId);

        public const string SsoAppSId = "e98d7c1c-f6d8-4370-822a-c0a4377e0a59";
        public const string AdminAppSId = "98E6825F-7702-4A83-B194-A25442A25D7A";
        public const string BlogAppSId = "D0E0D0F1-9A7E-4869-8295-DA9BBC072BAB";

        public const string AppAppSId = "1F301943-268F-4940-8BFB-900E0E6E0D35";
        public const string ConfigAppSId = "9158A492-C6AE-4C50-87A4-7ADB8BB8D36D";
        public const string DictAppSId = "21E87C50-B014-40BD-ADD7-01C64513FD3A";
        public const string MsgAppSId = "8600D55B-5F73-41F8-9D06-0F65710D3D80";
        
        public const string AccAppSId = "45672506-DDB7-4D57-AD44-BD0AB136B556";
        public const string EconAppSId = "18CC3E21-1B74-4BCD-BC5F-FF5E1E4E6C57";
        public const string DocAppSId = "7B3A90EC-8311-4113-B010-88E046D4D036";
        public const string HrAppSId = "D96AB61D-7556-4552-98D2-B3507FBF0E55";

        public const string CrmAppSId = "95e9e18f-0316-4c04-bedc-a8e321431c0a";
        public const string SrmAppSId = "379DD8C7-B603-4A45-BD23-72BAABEE374A";
        public const string PrdAppSId = "211D74B3-A43F-4167-8BAD-924AF898D570";
        public const string PmcAppSId = "82D4AEBE-45E8-46DA-83CA-DA3DF071D96E";

        public const string PortalAppSId = "AD401D87-0F1C-46DE-AE3E-BE4EC1C57D2C";
        public const string SomAppSId = "A328591D-A64D-4379-B70E-3BDD152848D1";
        public const string PomAppSId = "8A6CD786-582E-44BD-8F5A-E45266E0ABF7";
        public const string WmsAppSId = "418841DB-3A2A-4C75-9F7A-C0A14F6EE756";

        public const string MarketAppSId = "5A79FD6A-7DD9-45E6-B35B-AB24D32E89BB";

        public const string TrainAppSId = "6F0B2682-CCE6-4D7A-AF12-A609DE44EBA6";

        public const string FlowAppSId = "D6036537-1BEB-4818-AF7B-3AF493E0C930";
        public const string PayAppSId = "9376560F-FFDE-416F-B9E8-966B7A79012A";

        public const string WXapiAppSId = "26755248-3986-4C7C-9980-E353BAA85AC4";
        public const string ResapiAppSId = "3C2ADF22-0979-4392-873F-33DBEA51234D";

        public const string WebapiAppSId = "740b4c83-aa39-410f-a35d-6d427ac33311";

        //应用名称
        public const string SsoAppName = "统一认证系统";
        public const string AdminAppName = "租户管理";
        public const string BlogAppName = "博客管理";

        public const string AppAppName = "应用管理";
        public const string ConfigAppName = "配置管理";
        public const string DictAppName = "字典管理";
        public const string MsgAppName = "消息管理";
        
        public const string AccAppName = "账户管理";
        public const string EconAppName = "合同管理";
        public const string DocAppName = "文档管理";
        public const string HrAppName = "人事管理";

        public const string CrmAppName = "客户管理";
        public const string SrmAppName = "供应商管理";
        public const string PrdAppName = "商品管理";
        public const string PmcAppName = "物料管理";

        public const string PortalAppName = "门户网站";
        public const string SomAppName = "采购管理";
        public const string PomAppName = "销售管理";
        public const string WmsAppName = "仓储管理";
        
        public const string MarketAppName = "融资系统";

        public const string TrainAppName = "培训管理";

        public const string FlowAppName = "工作流管理";
        public const string PayAppName = "支付管理";

        public const string WXAppName = "微信管理";
        public const string ResapiAppName = "资源服务";
        public const string WebapiAppName = "接口管理";

        //应用Scope
        public const string OpenIdScope = "openid";
        public const string ProfileScope = "profile";
        public const string SsoScope = "ssoapi";
        public const string AdminScope = "adminapi";
        public const string BlogScope = "blogapi";

        public const string AppScope = "appapi";
        public const string CfgScope = "cfgapi";
        public const string DicScope = "dicapi";
        public const string MsgScope = "msgapi";
        
        public const string AccScope = "accapi";
        public const string EconScope = "econapi";
        public const string DocScope = "docapi";
        public const string HrScope = "hrapi";

        public const string CrmScope = "crmapi";
        public const string SrmScope = "srmapi";
        public const string PrdScope = "prdapi";
        public const string PmcScope = "pmcapi";

        public const string PortalScope = "portalapi";
        public const string SomScope = "somapi";
        public const string PomScope = "pomapi";
        public const string WmsScope = "wmsapi";

        public const string MarketScope = "jrapi";

        public const string TrainScope = "trainapi";

        public const string FlowScope = "flowapi";
        public const string PayScope = "payapi";

        public const string WXScope = "wxapi";
        public const string ResScope = "resapi";
        public const string WebapiScope = "webapi";

        #endregion

        public static List<ApplicationInfo> GetAllApplications()
        {
            return new List<ApplicationInfo>()
            {
                new ApplicationInfo(SsoAppId, SsoAppName, GlobalConfig.SSOWebDomain, SsoScope),
                new ApplicationInfo(AdminAppId, AdminAppName, GlobalConfig.AdminWebDomain, AdminScope),
                new ApplicationInfo(BlogAppId, BlogAppName, GlobalConfig.BlogWebDomain, BlogScope),

                new ApplicationInfo(AppAppId, AppAppName, GlobalConfig.AppWebDomain, AppScope),
                new ApplicationInfo(ConfigAppId, ConfigAppName, GlobalConfig.CfgWebDomain, CfgScope),
                new ApplicationInfo(DictAppId, DictAppName, GlobalConfig.DicWebDomain, DicScope),
                new ApplicationInfo(MsgAppId, MsgAppName, GlobalConfig.MsgWebDomain, MsgScope),

                new ApplicationInfo(AccAppId, AccAppName, GlobalConfig.AccWebDomain, AccScope),
                new ApplicationInfo(EconAppId, EconAppName, GlobalConfig.EconWebDomain, EconScope),
                new ApplicationInfo(DocAppId, DocAppName, GlobalConfig.DocWebDomain, DocScope),
                new ApplicationInfo(HrAppId, HrAppName, GlobalConfig.HrWebDomain, HrScope),

                new ApplicationInfo(CrmAppId, CrmAppName, GlobalConfig.CrmWebDomain, CrmScope),
                new ApplicationInfo(SrmAppId, SrmAppName, GlobalConfig.SrmWebDomain, SrmScope),
                new ApplicationInfo(PrdAppId, PrdAppName, GlobalConfig.PrdWebDomain, PrdScope),
                new ApplicationInfo(PmcAppId, SrmAppName, GlobalConfig.PmcWebDomain, PmcScope),

                new ApplicationInfo(PortalAppId, PortalAppName, GlobalConfig.PortalWebDomain, PortalScope),
                new ApplicationInfo(SomAppId, SomAppName, GlobalConfig.SomWebDomain, SomScope),
                new ApplicationInfo(PomAppId, PomAppName, GlobalConfig.PomWebDomain, PomScope),
                new ApplicationInfo(WmsAppId, WmsAppName, GlobalConfig.WmsWebDomain, WmsScope),

                new ApplicationInfo(MarketAppId, MarketAppName, GlobalConfig.JRWebDomain, MarketScope),
                new ApplicationInfo(TrainAppId, TrainAppName, GlobalConfig.TrainWebDomain, TrainScope),

                new ApplicationInfo(FlowAppId, FlowAppName, GlobalConfig.FlowWebDomain, FlowScope),
                new ApplicationInfo(PayAppId, PayAppName, GlobalConfig.PayWebDomain, PayScope),

                new ApplicationInfo(WXapiAppId, WXAppName, GlobalConfig.WXWebDomain, WXScope),
                new ApplicationInfo(ResapiAppId, ResapiAppName, GlobalConfig.ResWebDomain, ResScope),
                new ApplicationInfo(WebapiAppId, WebapiAppName, GlobalConfig.ApiWebDomain, WebapiScope),
            };
        }

        public const string ClientAuthorityId = "5DE763F5-3E85-4A2A-8203-31D11FE9599D";
        public const string DefaultAuthorityId = "126AC4CF-84CF-410B-8989-A4EB8397EC3F";

        public const char DefaultAuthoritySplitChar = ':';

        /// <summary>
        /// 租户存储限制：1000
        /// </summary>
        public const int StorageLimit = 1000;

        /// <summary>
        /// 数据库实例限制：20
        /// </summary>
        public const int DatabaseLimit = 20;

        #region 模块相关的ID
        //SSO系统模块
        public static readonly Guid SsoAdminModuleId = new Guid("459E2E67-0214-4312-8D81-E87BE17F7FA2");
        public static readonly Guid SsoAccountModuleId = new Guid("BEDE1EB4-1FF0-493A-AE5F-209A984FE07A");

        //CRM系统模块
        public static readonly Guid CrmBasicModuleId = new Guid("80ad21fd-f151-4b3b-b730-363da73c92a9");

        //电商系统模块
        public static readonly Guid ShopBasicModuleId = new Guid("BF93BF66-8E30-4079-9A1E-1725F1DE80C7");
        public static readonly Guid ShopOfferingModuleId = new Guid("822c2e08-f7ad-4028-aa5c-a92b88d1a78a");
        public static readonly Guid ShopOrderModuleId = new Guid("0766a4b1-b096-4fc5-87cc-b6357e489e07");

        //融资系统模块
        public static readonly Guid MarketBasicModuleId = new Guid("8EB32DF9-79A3-4D8B-BA0C-C7019C4BA770");
        public static readonly Guid MarketOfferingModuleId = new Guid("FD6E3A75-3B32-4C6A-94BE-07859E42D3F0");
        public static readonly Guid MarketOrderModuleId = new Guid("52927433-22D5-4542-87AB-9643D1FE2CAB");
        public static readonly Guid MarketCreditLevelModuleId = new Guid("AD31E9DD-329C-44FE-BCFA-E7E5BC8BF00F");
        public static readonly Guid MarketFinancingCreditModuleId = new Guid("AB44E44B-42E2-460B-B29F-A0D4EB61F6C3");

        //ERP系统模块
        public static readonly Guid ErpBasicModuleId = new Guid("5F891E90-5B67-4922-B2A0-39D306075761");
        public static readonly Guid ErpFinanceModuleId = new Guid("99A8E38A-883A-4F87-BEBD-80A38A4B67B8");
        public static readonly Guid ErpScmModuleId = new Guid("6B58B8DF-53BB-4191-A118-C5D8D883099E");
        public static readonly Guid ErpArapModuleId = new Guid("EC0DC963-99EE-4D30-B43B-8C1C3A24E534");
        public static readonly Guid ErpCashierModuleId = new Guid("3861A564-7451-47F0-BE12-90BA6859B463");

        //Workflow系统模块
        public static readonly Guid WorkflowBasicModuleId = new Guid("8918ABC6-2CF7-4A62-AA3A-B86699D0D2F8");
        #endregion

    }
}
